package cn.clazz

/**
  * Created by lzd on 2018/9/5.
  */
class Person(val name:String,val age:Int) {
  println("主构造器会执行类定义中的所有语句")

  val x = 1
  if(x>1){
    println("6666")
  }else if(x<1){
    println("哈哈")
  }else{
    println("呵呵")
  }

  private var address = "BJ"

  def this(name:String,age:Int,address:String){
    this(name,age)
    println("执行辅助构造器")
    this.address = address
  }
}

object Person{
  def main(args: Array[String]): Unit = {
    val p = new Person("dengchao",33,"Sh")
    println(p.address)
    println(p.age)
    println(p.name)
  }
}
